package com.yty.demo._3_grammar;

import java.util.Scanner;

/**
 * @author: yangtaoyao
 * @time: 2020/1/6$ 15:58$
 * @description: 运算符
 */
public class OperatorTest {
    public static void main(String[] args) {
        int i1=10,i2=20;
        int i=i1++;
        System.out.println(i);
        System.out.println(i1);
        System.out.println("======================");
        i=++i1;
        System.out.println(i);
        System.out.println(i1);
        System.out.println("=======================");
        i=i2--;
        System.out.println(i);
        System.out.println(i2);
        System.out.println("=======================");
        i=--i2;
        System.out.println(i);
        System.out.println(i2);

        System.out.println("=======&& &=======");
        System.out.println(checkBoolean("left",false)&checkBoolean("right",false));
        System.out.println(checkBoolean("left",false)&&checkBoolean("right",false));

        System.out.println("========|| |=======");
        System.out.println(checkBoolean("left",true)|checkBoolean("right",true));
        System.out.println(checkBoolean("left",true)||checkBoolean("right",true));
        System.out.println("=========================");

        /**
         * 异或
         */
        System.out.println("=========================");
        System.out.println(false^true);
        System.out.println(true^false);
        System.out.println(false^false);
        System.out.println(true^true);

        /**
         * 位运算符 >>  <<  >>>  &  ~  |  ^
         */
        System.out.println("=========================");
        System.out.println(1<<2);
//        input();
        System.out.println("=========================");
        /**
         * 三元运算
         */
        int x1=11,x2=9,x3=5;
        System.out.println(x1>x2?(x1>x3?x1:x3):x2);
        System.out.println("=========================");

    }

    public static void input(){
        boolean b=true;
        Scanner in=new Scanner(System.in);
        String s=null;
        int i1=0;
        int i2=0;
        while (b){
            String s1=in.nextLine();
            if(s1.equals("exit")){
                return;
            }
            i1=in.nextInt();
            i2=in.nextInt();
            System.out.println(i1>>i2);
        }
    }

    public static boolean checkBoolean(String s, boolean b){
        System.out.println("==="+s+"====");
        return b;
    }
}
